package cn.edu.wfit.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/users")
public class UsersController {
    @GetMapping
    public String hello(){
        return "hello";
    }
    @GetMapping("role")
    @PreAuthorize("hasRole('user')") // 直接使用hasRole方法判断是否包含某个角色
    public String role(){
        return "hello user";
    }
    @GetMapping("role2")
    @PreAuthorize("hasRole('admin')") // 直接使用hasRole方法判断是否包含某个角色
    public String roleadmin(){
        return "hello admin";
    }
}
